using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace ArchSoft
{
    public class ArchsoftProcessor
    {
        public static void PutLayoutMenuItems( ToolStripMenuItem publishMenuItem, EventHandler functionMenu ,ToolStripMenuItem pdfMnu, EventHandler PdfFunct)
        {
            try
            {
                if ((string)publishMenuItem.Tag != AutocadHelper.Instance.TemplateFileForPublishing)
                {
                    pdfMnu.DropDownItems.Clear();
                    publishMenuItem.DropDownItems.Clear();
                }
                else
                    return;

                if (AutocadHelper.Instance.TemplateFileForPublishing == string.Empty)
                    return;

                List<string> pageList = AutocadHelper.Instance.PageSetupList;
                foreach (string item in pageList)
                {
                    //ToolStripItem itemMenu = publishMenuItem.DropDownItems.Add(item);
                    //itemMenu.Click += new EventHandler(functionMenu);

                    //TAM THOI KO CARE PDF or NOT
                    //if (item.ToLower().IndexOf("pdf") < 0)
                    //{
                    if (item.IndexOf("PDF") < 0)
                    {
                        ToolStripItem itemMenu = publishMenuItem.DropDownItems.Add(item);
                        itemMenu.Click += new EventHandler(functionMenu);
                    }
                    //}
                    //else
                    //{
                    //    ToolStripItem itemMenu = pdfMnu.DropDownItems.Add(item);
                    //    itemMenu.Click += new EventHandler(PdfFunct);
                    //}
                }
                publishMenuItem.Enabled = pageList.Count > 0;
                publishMenuItem.Tag = AutocadHelper.Instance.TemplateFileForPublishing;
            }
            catch {}//(Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
    }
}
